#include "MainWindow.h"
#include "Item.h"

MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
{
	_scene = new Scene;
	
	_view = new QGraphicsView(_scene);

	createMenus();
	
	this->setCentralWidget(_view);
}

void MainWindow::createMenus()
{
    fileMenu = menuBar()->addMenu(tr("File"));
    //newAct  = new QAction( tr("Nouveau"), this );
    openAct = new QAction( tr("Ouvrir"),  this );
    saveAct = new QAction( tr("Sauver"),  this );
    quitAct = new QAction( tr("Quitter"), this );
    //newAct ->setShortcut( QKeySequence("Ctrl+X, Ctrl+F") );
    openAct->setShortcut( QKeySequence("Ctrl+X, Ctrl+F") );
    saveAct->setShortcut( QKeySequence("Ctrl+X, Ctrl+S") );
    quitAct->setShortcut( QKeySequence("Ctrl+X, Ctrl+C") );
    // connect(newAct, SIGNAL(triggered()), this, SLOT(load()));
    connect( quitAct, SIGNAL(triggered()), qApp, SLOT(quit()) );
    //fileMenu->addAction( newAct );
    fileMenu->addAction( openAct );
    fileMenu->addAction( saveAct );
    fileMenu->addAction( quitAct );

    createMenu = menuBar()->addMenu(tr("Item"));
    addAct    = new QAction( tr("Ajouter"),   this );
    deleteAct = new QAction( tr("Supprimer"), this );
    copyAct   = new QAction( tr("Copier"),    this );
    addAct   ->setShortcut( QKeySequence("Ctrl+C, Ctrl+N") );
    deleteAct->setShortcut( QKeySequence("Ctrl+C, Ctrl+D") );
    copyAct  ->setShortcut( QKeySequence("Alt+W") );
    connect( addAct, SIGNAL(triggered()), this, SLOT(addItem()) );
    createMenu->addAction( addAct    );
    createMenu->addAction( deleteAct );
    createMenu->addAction( copyAct   );
}

void MainWindow::addItem()
{
    Item* item = new Item();
    
    _scene->addItem(item);
}

    
